import request from '@/utils/request'

const BASE_URL = '/erp/api/website/'

export function Get(id, args) {
  return request({
    url: `${BASE_URL}${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function Post(data) {
  return request({
    url: BASE_URL,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function Put(id, data) {
  return request({
    url: `${BASE_URL}${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: JSON.stringify(data)
  })
}

export function Delete(id) {
  return request({
    url: `${BASE_URL}${id || ''}`,
    method: 'delete'
  })
}

export function dt(data) {
  return request({
    url: `${BASE_URL}dt`,
    method: 'post',
    data: data
  })
}

export function Sync(mode, id) {
  return request({
    url: `${BASE_URL}sync/${mode}/${id || ''}`,
    method: 'post',
    timeout: 150000
  })
}

export function P2W(data) {
  return request({
    url: '/erp/api/p2w/update/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: JSON.stringify(data)
  })
}

export function CatalogTree(id) {
  return request({
    url: `${BASE_URL}catalog_tree/${id || ''}`,
    method: 'get'
  })
}

export function AssociationTree(id) {
  return request({
    url: `${BASE_URL}association_tree/${id || ''}`,
    method: 'get'
  })
}

export function ShowSyncStatus(id) {
  return request({
    url: `${BASE_URL}sync/status/${id || ''}`,
    method: 'get'
  })
}

export function AddCategory(data) {
  return request({
    url: `${BASE_URL}catalog_tree/`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: JSON.stringify(data),
    timeout: 200000
  })
}

export function DeleteCategory(data) {
  return request({
    url: `${BASE_URL}catalog_tree/`,
    headers: { 'content-type': 'application/json' },
    method: 'delete',
    data: JSON.stringify(data),
    timeout: 200000
  })
}

export function GetCategoryDetail(data) {
  return request({
    url: `${BASE_URL}category_detail/`,
    method: 'post',
    data: JSON.stringify(data),
    timeout: 200000
  })
}

export function AddCrawlWebProduct(id) {
  return request({
    url: `${BASE_URL}add_crawl_web_product/${id || ''}`,
    method: 'get'
  })
}

export function GetWebsiteStateOptions() {
  return [
    {
      label: '新建网站',
      value: 'new'
    },
    {
      label: '模板完成',
      value: 'theme_finished'
    },
    {
      label: '已经审核',
      value: 'submit_to_google'
    },
    {
      label: '审核通过',
      value: 'google_passed'
    },
    {
      label: '批量上传',
      value: 'uploading'
    },
    {
      label: '等待广告',
      value: 'normal_running'
    },
    {
      label: '新上广告',
      value: 'ads_firstweek'
    },
    {
      label: '冲刺流量',
      value: 'ads_getmoretraffic'
    },
    {
      label: '广告运行',
      value: 'ads_running'
    },
    {
      label: '暂停广告',
      value: 'ads_stop'
    },
    {
      label: 'Bing广告运行',
      value: 'ads_bing_running'
    },
    {
      label: 'facebook广告运行',
      value: 'ads_facebook_running'
    },
    {
      label: 'GMC已封',
      value: 'gms_suspend'
    },
    {
      label: 'BingAds已封',
      value: 'bing_suspend'
    },
    {
      label: 'Facebook已封',
      value: 'facebook_suspend'
    }
  ]
}

